#include "types.h"
#include "pmm.h"
#include "kalloc.h"
#include "printf.h"
#include "assert.h"
#include "test_pmm.h"

void test_physical_memory() {
    printf("=== Physical Memory Test ===\n");
    
    // 基础分配测试
    void *p1 = alloc_page();
    void *p2 = alloc_page();
    assert(p1 != p2);
    assert((uint64)p1 % PGSIZE == 0);

    // 数据读写验证
    *(uint64*)p1 = 0xCAFEBABE;
    assert(*(uint64*)p1 == 0xCAFEBABE);

    // 释放与重用测试
    free_page(p1);
    void *p3 = alloc_page();
    assert(p3 == p1);  // LIFO策略应返回最近释放的页

    printf("Test Passed\n\n");
}
